package com.yy.jhl.ui.user.presenter;

import com.google.gson.Gson;
import com.yy.common.basebean.BaseResponse;
import com.yy.jhl.api.Api;
import com.yy.jhl.api.RxSubscriber;
import com.yy.jhl.bean.LoginInfo;
import com.yy.jhl.ui.user.contract.RegisterContract;

import org.json.JSONException;
import org.json.JSONObject;

import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * Created by Ellis.Li on 2017/8/30.
 */

public class RegisterPresenter extends RegisterContract.Presenter {
    @Override
    public void register(String phone,String email,String code,String password,String confirm_password,int agree_me) {
        RequestBody requestBody = new FormBody.Builder()
                .add("phone", phone)
                .add("code", code)
                .add("password", password)
                .add("confirm_password", confirm_password)
                .add("agree_me", agree_me+"")
                .build();
        mRxManage.addSubscription(Api.getDefault().register(requestBody), new RxSubscriber<ResponseBody>(mContext, true) {
            @Override
            protected void _onNext(String result) {
                mView.registerSuccess();
            }

            @Override
            protected void _onError(String message) {
                mView.registerFail();
            }
        });

    }
}
